package com.rad.datastat.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.rad.datastat.utils.ArrivalPrefs;
import com.rad.net.protocol.android.utils.LogUtils;

public class USBConnectReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		if (intent == null || intent.getAction() == null) {
			return;
		}

		if (intent.getAction().equals("android.hardware.usb.action.USB_STATE")) {
			if (intent.getExtras().getBoolean("connected")) {
				LogUtils.i("USBConnectReceiver", "Connected=true");
				ArrivalPrefs.setUsbConnected(context, true);
			} else {
				LogUtils.i("USBConnectReceiver", "Connected=false");
				ArrivalPrefs.setUsbConnected(context, false);
			}
		}
		//		if(intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) {
		//			//是否处于充电状态,是否是USB方式充电
		//			if(intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1) == BatteryManager.BATTERY_STATUS_CHARGING
		//					&& intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) == BatteryManager.BATTERY_PLUGGED_USB){
		//				sConnected = true;
		//			} else {
		//				sConnected = false;
		//			}
		//		}
	}
}
